// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import Character from "../../../BASE/Character";
import GeZiManager from "../../../Manager/GeZiManager";
import MessageCenter from "../../../Message/MessageCenter";
import Qiang from "./Qiang";

const {ccclass, property} = cc._decorator;


//火箭筒
@ccclass
export default class A261 extends Qiang {
    BT: boolean = true;//是否耗费子弹
    BTS: number = 1;//子弹数
    SH = 3;//伤害
    TheNumber: string = "A261";//编号，用于识别武器
    level: number=6;

    QD(an:number[]){
  
        console.log(this.node.getComponent(Character).Pturn)
        if(this.node.getComponent(Character).attack2!=null){for(let a of this.node.getComponent(Character).attack2){a.Attack2(an);}}

        //距离大于2才发信息
        if( this.SH,this.node.getComponent(Character).getdis(an[0])>2){
            MessageCenter.MakeSHMessage("AM", an, this.SH,this.node.getComponent(Character).Pturn, "wuli");
            //对目标9宫格造成1点伤害 分两个部分最外圈不够九宫格部分和内部够九宫格部分
            if(an[0]>=1&&an[0]<=8){
                if(an[0]==1){
                    MessageCenter.MakeSHMessage("AM", [an[0]+1], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]+8], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]+9], 1,this.node.getComponent(Character).Pturn, "wuli");
                }
                else if(an[0]==8){
                    MessageCenter.MakeSHMessage("AM", [an[0]-1], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]+8], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]+7], 1,this.node.getComponent(Character).Pturn, "wuli");
                }
                else{
                    MessageCenter.MakeSHMessage("AM", [an[0]+1], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]-1], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]+7], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]+8], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]+9], 1,this.node.getComponent(Character).Pturn, "wuli");
                }
              
            }
            else if(an[0]>=57){
                if(an[0]==57){
                    MessageCenter.MakeSHMessage("AM", [an[0]+1], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]-8], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]-7], 1,this.node.getComponent(Character).Pturn, "wuli");
                }
                else if(an[0]==64){
                    MessageCenter.MakeSHMessage("AM",[ an[0]-1], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]-8], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]-9], 1,this.node.getComponent(Character).Pturn, "wuli");
                }
                else{
                    MessageCenter.MakeSHMessage("AM", [an[0]+1], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]-1], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]-7], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]-8], 1,this.node.getComponent(Character).Pturn, "wuli");
                    MessageCenter.MakeSHMessage("AM", [an[0]-9], 1,this.node.getComponent(Character).Pturn, "wuli");
                }

              
            }
            else if(an[0]%8==1){
                MessageCenter.MakeSHMessage("AM", [an[0]+1], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]+8], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]+9], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]-8], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]-7], 1,this.node.getComponent(Character).Pturn, "wuli");

            }
            else if(an[0]%8==0){
                MessageCenter.MakeSHMessage("AM", [an[0]-1], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]+7], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]+8], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]-8], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]-9], 1,this.node.getComponent(Character).Pturn, "wuli");
            }
            else {
                MessageCenter.MakeSHMessage("AM", [an[0]+1], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]-1], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]+7], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]-7], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]+8], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]-8], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]+9], 1,this.node.getComponent(Character).Pturn, "wuli");
                MessageCenter.MakeSHMessage("AM", [an[0]-9], 1,this.node.getComponent(Character).Pturn, "wuli");
            }
        }
         

          if(this.node.getComponent(Character).attack3!=null){for(let a of this.node.getComponent(Character).attack3){a.Attack3(an);}}
        
        MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],this.getTNC(3)+this.TNJ,this.node.getComponent(Character).Pturn,"TN-")
      GeZiManager.PCP.TNC(GeZiManager.PCP.TN);
      GeZiManager.TNC[3]=4
      GeZiManager.Bu.push(2);}
      
    }
  
    
    // update (dt) {}
